package com.xiaochong.tir.manager.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaochong.tir.common.data.mapper.ExchangeDimensionMiddleMapper;
import com.xiaochong.tir.common.data.mapper.TimeDimensionMapper;
import com.xiaochong.tir.common.data.po.ExchangeDimensionMiddle;
import com.xiaochong.tir.common.data.po.TimeDimension;
import com.xiaochong.tir.manager.config.druid.Operation;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 此类为[基础代码]自动生成,已经拥有基本的增删改成操作 
 * <其他请自行扩展>
 * @author cx
 * @time 2018-06-06 09:53
 * 
 */
@Service
public class ExchangeDimensionMiddleService{
 
      
    @Autowired
	private ExchangeDimensionMiddleMapper exchangeDimensionMiddleDao;
    @Autowired
    private TimeDimensionMapper timeDimensionDao;
	
	/**
     * 新增
     * @param entity 
     * @param session
     */
	@Operation
    @Transactional
    public int insertSelective (ExchangeDimensionMiddle entity) {
     return this.exchangeDimensionMiddleDao.insertSelective(entity);
    }	
    
    /**
     * 批量新增
     * @param list 
     * @param session
     */
    public void insertBatch(List<ExchangeDimensionMiddle> list) {
           
          this.exchangeDimensionMiddleDao.insertBatch(list);
         
         
    }
    
    /**
     * 根据主键修改单条数据
     * @param entity 
     * @param session
     */
    @Operation
    @Transactional
    public int updateByPrimaryKey(ExchangeDimensionMiddle entity,ExchangeDimensionMiddle old) {
           return this.exchangeDimensionMiddleDao.updateByPrimaryKey(entity);
    }
    
    /**
     * 根据主键批量修改数据
     * @param list 
     * @param session
     */
    public void updateBatch(List<ExchangeDimensionMiddle> list) {
           
          this.exchangeDimensionMiddleDao.updateBatch(list);
          
        
    }
    
    /**
     * 根据主键查询单条数据
     * @param id
     */
    public ExchangeDimensionMiddle selectByPrimaryKey(Integer id) {
            return this.exchangeDimensionMiddleDao.selectByPrimaryKey(id);
    }
    
    /**
     * 根据条件查询单条记录
     * @param entity 
     */
    public ExchangeDimensionMiddle selectByEntity(ExchangeDimensionMiddle entity) {
           return this.exchangeDimensionMiddleDao.selectByEntity(entity);
    }
    
    
    /**
     * 根据条件查询多条记录
     * @param entity 
     */
    public List<ExchangeDimensionMiddle> selectByEntityList(ExchangeDimensionMiddle entity) {
           return  this.exchangeDimensionMiddleDao.selectByEntityList(entity);
    }
    
    /**
     * 根据条件查询Id
     * @param entity 
     */
    public Integer selectById(ExchangeDimensionMiddle entity) {
           return  this.exchangeDimensionMiddleDao.selectById(entity);
    }
    
     /**
     * 根据条件查询Ids
     * @param entity 
     */
    public List<Integer> selectByIds(ExchangeDimensionMiddle entity) {
        return  this.exchangeDimensionMiddleDao.selectByIds(entity);
    }
    
     /**
     * 根据主键删除单条记录
     * @param id
     */
     @Operation
     @Transactional
    public void deleteByPrimaryKey(Integer id,ExchangeDimensionMiddle old) {
        this.exchangeDimensionMiddleDao.deleteByPrimaryKey(id);
    }

    public void deleteByPrimaryKeys(Integer id) {
        this.exchangeDimensionMiddleDao.deleteByPrimaryKey(id);
    }
    
    /**
     * 根据主键删除多条记录
     * @param list
     */
    public void deleteBatch(List<Integer> list) {
           this.exchangeDimensionMiddleDao.deleteBatch(list);
    }
    
     /**
     * 根据某些条件删除
     * @param entity
     */
    public void deleteBatch(ExchangeDimensionMiddle entity) {
           this.exchangeDimensionMiddleDao.deleteByEntity(entity);
    }


    public PageInfo<ExchangeDimensionMiddle> selectByMiddleList(ExchangeDimensionMiddle exchangeDimensionMiddle, Integer pageSize, Integer pageIndex) {
        PageHelper.startPage(pageIndex,pageSize);
        PageInfo<ExchangeDimensionMiddle> pageInfo =
                new PageInfo<ExchangeDimensionMiddle>(this.exchangeDimensionMiddleDao.selectByEntityList(exchangeDimensionMiddle));
        return pageInfo;
    }

    public PageInfo<TimeDimension> selTimeDimension(TimeDimension timeDimension, Integer pageSize, Integer pageIndex) {
        PageHelper.startPage(pageIndex,pageSize);
        List<TimeDimension> dList= timeDimensionDao.selTimeDimension(timeDimension);
        PageInfo<TimeDimension> pageInfo = new PageInfo<TimeDimension>(dList);
        return pageInfo;
    }

    public int updateByName(ExchangeDimensionMiddle dimensionMiddle) {
        return this.exchangeDimensionMiddleDao.updateByName(dimensionMiddle);
    }
}